<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 00:33:05
 * @LastEditTime: 2023-08-28 14:22:43
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description: BOM成品工艺
 */

namespace App\Models;

use App\Traits\MaterialTrait;
use App\Traits\AutoCodeTrait;

class ProPotRawSend extends BaseModel
{
    use MaterialTrait;
    use AutoCodeTrait;
    /**
     * 标识
     *
     * @var string
     */
    protected $ACSign = 'RAW_SEND_CODE';
    public $timestamps = true;

    public $table = "sys_pro_pot_raw_send";
    protected $guarded = [];

    public function details()
    {
        return $this->hasMany(ProPotRawSendDetail::class, "main_id");
    }
    //辅料，助剂染化料单，有配料单，加料单，多个
    public function storage()
    {
        return $this->hasMany(ProPotRawSendStorage::class, "raw_id");
    }
    public function status()
    {
        return $this->belongsTo(Dic::class, "status_id", "key")->where(function ($q) {
            $q->where("code", 'StorageOut');
        });
    }
    public function pro_pot()
    {
        return $this->belongsTo(ProPot::class);
    }
}
